package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Role;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RoleDTO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "角色编码")
    private String roleCode;

    @ApiModelProperty(value = "角色姓名")
    private String roleName;

    @ApiModelProperty(value = "别名")
    private String antherName;

    @ApiModelProperty(value = "数据权限类型")
    private Integer dataAuthType;

    @ApiModelProperty(value = "是否启用：1启用0禁用")
    private Integer enable;

    @ApiModelProperty(value = "角色说明")
    private String remark;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;


    public RoleDTO() {}

    public RoleDTO(Role entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static RoleDTO convert(Role entity) {
        return new RoleDTO(entity);
    }

    public static List<RoleDTO> convertList(List<Role> list) {
        List<RoleDTO> resultList = new ArrayList<>();
        for (Role entity : list) {
            resultList.add(new RoleDTO(entity));
        }
        return resultList;
    }}
